<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib tagdir="/WEB-INF/tags" prefix="tag" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ page isELIgnored="false"%>
<%
%>

<table>
<c:forEach var="msg" items="${messageList}">
 <tr>
  <td>暱稱</td><td>${msg.nick}</td>
  <td>標題</td><td>${msg.subject}</td>
  <td>時間</td><td>${msg.createTime}</td>
  <td><input type="button" value="回應" onclick="alert('尚未實作')"/></td>
 </tr>
 <tr>
  <td colspan="7">${msg.content}</td>
 </tr>
</c:forEach>
</table>
共 ${fn:length(messageList)} 筆留言
<c:if test="${from>0}"><a href="${ctxPath}/guestbook_list_message.do?from=${previous}&count=${count}">上一頁</a></c:if>
<c:if test="${hasNextPage}"><a href="${ctxPath}/guestbook_list_message.do?from=${from+count}&count=${count}">下一頁</a></c:if>
<input type="button" value="建立新留言" onclick="S('divPost').display = ''"/>
<div id="divPost" style="display:none">
 <html:form styleId="guestbook_new_form" action="${ctxPath}/guestbook_new.do" method="post"
 	onsubmit="return jsonSubmit(this)">
  <table>
   <tr>
 	<td>暱稱</td><td><html:text property="nick"/></td>
   </tr>
   <tr>
 	<td>電子郵件</td><td><html:text property="email"/></td>
   </tr>
   <tr>
 	<td>標題</td><td><html:text property="subject"/></td>
   </tr>
   <tr>
 	<td>內容</td><td><html:textarea property="content"/></td>
   </tr>
   <tr>
 	<td colspan="2" style="text-align:right">
 	 <input type="button" value="放棄" onclick="S('divPost').display='none'"/>
 	 <input type="reset" value="重寫"/>
 	 <input type="submit" value="送出"/>
 	</td>
   </tr>
  </table>
 </html:form>
</div>
<div id="divSuccess" style="display:none">
  您已成功送出留言， <a id="aViewMessage" href="#">按此檢視</a>您剛才送出的留言
</div>